package com.fansl.allround.study.spring.singlebean;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Service;

/**
 * @author fansl
 * @Description: 如何在单例Bean中注入原型Bean
 * https://mp.weixin.qq.com/s/OTRiKwE7Mk1PaX3q0WAPqQ
 * @date 2019/10/11 9:59
 */
@Service
public class UserServiceImpl1 implements ApplicationContextAware {

    private ApplicationContext context;

    public OrderService getOrderService(){
        return context.getBean(OrderService.class);
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.context = applicationContext;
    }
}
